# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

resources:
{% if properties["small-tpu"] %}
- type: gcp-types/container-v1beta1:projects.locations.clusters.nodePools
  name: small-tpu-pool
  properties:
    parent: projects/{{ env["project"] }}/locations/us-central1/clusters/{{ properties["cluster-name"] }}
    nodePool:
      name: small-tpu-pool
      initialNodeCount: 1
      autoscaling:
        enabled: true
        minNodeCount: 1
        maxNodeCount: 5
      locations:
      - us-central1-b
      config:
        machineType: e2-highmem-16
        oauthScopes:
        - https://www.googleapis.com/auth/cloud-platform
        labels:
          tpu-available: "true"
{% endif %}
{% if properties["huge-tpu"] %}
- type: gcp-types/container-v1beta1:projects.locations.clusters.nodePools
  name: huge-tpu-pool
  properties:
    parent: projects/{{ env["project"] }}/locations/us-central1/clusters/{{ properties["cluster-name"] }}
    nodePool:
      name: huge-tpu-pool
      initialNodeCount: 0
      autoscaling:
        enabled: true
        minNodeCount: 0
        maxNodeCount: 5
      locations:
      - us-central1-b
      config:
        machineType: n1-highmem-96
        oauthScopes:
        - https://www.googleapis.com/auth/cloud-platform
        labels:
          tpu-available: "true"
        taints:
        - key: expensive
          value: cpu
          effect: PREFER_NO_SCHEDULE
{% endif %}
{% if properties["gpu-v100x4"] %}
- type: gcp-types/container-v1beta1:projects.locations.clusters.nodePools
  name: gpu-v100x4-pool
  properties:
    parent: projects/{{ env["project"] }}/locations/us-central1/clusters/{{ properties["cluster-name"] }}
    nodePool:
      name: gpu-v100x4-pool
      initialNodeCount: 0
      autoscaling:
        enabled: true
        minNodeCount: 0
        maxNodeCount: 5
      locations:
      - us-central1-c
      config:
        machineType: n1-standard-16
        accelerators:
        - acceleratorType: nvidia-tesla-v100
          acceleratorCount: 4
        oauthScopes:
        - https://www.googleapis.com/auth/cloud-platform
        taints:
        - key: expensive
          value: gpu
          effect: PREFER_NO_SCHEDULE
{% endif %}
{% if properties["gpu-v100x8"] %}
- type: gcp-types/container-v1beta1:projects.locations.clusters.nodePools
  name: gpu-v100x8-pool
  properties:
    parent: projects/{{ env["project"] }}/locations/us-central1/clusters/{{ properties["cluster-name"] }}
    nodePool:
      name: gpu-v100x8-pool
      initialNodeCount: 0
      autoscaling:
        enabled: true
        minNodeCount: 0
        maxNodeCount: 5
      locations:
      - us-central1-c
      config:
        machineType: n1-standard-16
        accelerators:
        - acceleratorType: nvidia-tesla-v100
          acceleratorCount: 8
        oauthScopes:
        - https://www.googleapis.com/auth/cloud-platform
        taints:
        - key: expensive
          value: gpu
          effect: PREFER_NO_SCHEDULE
{% endif %}
{% if properties["gpu-k80x8"] %}
- type: gcp-types/container-v1beta1:projects.locations.clusters.nodePools
  name: gpu-k80x8-pool
  properties:
    parent: projects/{{ env["project"] }}/locations/us-central1/clusters/{{ properties["cluster-name"] }}
    nodePool:
      name: gpu-k80x8-pool
      initialNodeCount: 0
      autoscaling:
        enabled: true
        minNodeCount: 0
        maxNodeCount: 10
      locations:
      - us-central1-c
      config:
        machineType: n1-standard-32
        accelerators:
        - acceleratorType: nvidia-tesla-k80
          acceleratorCount: 8
        oauthScopes:
        - https://www.googleapis.com/auth/cloud-platform
        taints:
        - key: expensive
          value: gpu
          effect: PREFER_NO_SCHEDULE
{% endif %}
{% if properties["gpu-a100x4"] %}
- type: gcp-types/container-v1beta1:projects.locations.clusters.nodePools
  name: gpu-a100x4-pool
  properties:
    parent: projects/{{ env["project"] }}/locations/us-central1/clusters/{{ properties["cluster-name"] }}
    nodePool:
      name: gpu-a100x4-pool
      initialNodeCount: 0
      autoscaling:
        enabled: true
        minNodeCount: 0
        maxNodeCount: 2
      locations:
      - us-central1-c
      config:
        machineType: a2-highgpu-4g
        accelerators:
        - acceleratorType: nvidia-tesla-a100
          acceleratorCount: 4
        oauthScopes:
        - https://www.googleapis.com/auth/cloud-platform
        taints:
        - key: expensive
          value: gpu
          effect: PREFER_NO_SCHEDULE
{% endif %}
